home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekkan Dennou Club 147
/
Gekkan Dennou Club - 2000.8 Vol. 147 (Japan).7z
/
Gekkan Dennou Club - 2000.8 Vol. 147 (Japan) (Track 1).bin
/
tools
/
zmc3v078
/
zmc3v078.lzh
/
SRCSV078.LZH
/
PORTAMNT.C
< prev
next >
Wrap
C/C++ Source or Header
|
2000-02-27
|
5KB
|
224 lines
/* ==========================================
@ series (@v, @b, @r, ... ) conversion
and... many subroutines
========================================== */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "etc.h"
#include "makezmd2.h"
#include "makezmd3.h"
#include "parsesub.h"
#include "velo.h"
#include "68lib.h"
#include "structs.h"
#include "structs2.h"
UBYTE *makePortament(UBYTE *zms,TRKCHINF *trkdata, const BYTE target[],
TRKINF *trkinf,COMMONINF *cominf,const char endchar);
UBYTE *makeZmdAutoPortament(UBYTE *zms, TRKCHINF *trkdata,
TRKINF *trkinf, const BYTE target[]);
UBYTE *makeZmdAutoPortamentSwitch(UBYTE *zms, TRKCHINF *trkdata, const BYTE target[]);
extern DWORD line;
extern char *linebuf;
extern LINEDATA *ld;
UBYTE *makePortament(UBYTE *zms,TRKCHINF *trkdata, const BYTE target[],
TRKINF *trkinf,COMMONINF *cominf, const char endchar)
{
LINEDATA *ld_ = ld;
UBYTE *linebuf_ = linebuf;
UBYTE *zms_ = zms;
int trk;
for (trk = 0; target[trk] >= 0; trk++) {
const int Trk = target[trk];
UBYTE note[9];
VELOETCVAR v[9];
UWORD step_, gate_, gate0;
WORD delay = trkinf[Trk].pdelay;
WORD ptime = trkinf[Trk].ptime;
BYTE *qpos = &(trkinf[Trk].quantizepos);
int notes;
BYTE relvelo = 0;
WORD br,add,cor,velo = -1;
/* const BYTE vnum = trkinf[Trk].veloznum; */
ld = ld_;
zms = makePortChord(zms_,Trk,trkinf,cominf,
endchar,1,v,note,¬es,
&step_,&gate_,&gate0,&delay,&ptime);
if (notes != 2) {
/* zmserror("portament requires 2 tones.",line_,linebuf_,zms_,0,1); */
if (checkCommonCommand(zms_,notes,note,step_,ld_->line,linebuf_,cominf)) {
return zms; /* if (d0) || (d1), return at once */
}
} else if (delay < 0) {
zmserror("delay must not be under zero.",ld_->line,linebuf_,zms_,0,1);
} else if (!step_) {
zmserror("illegal step length.",ld_->line,linebuf_,zms,0,1);
}
{ /* add v0.72 */
int i, p = -1;
for (i = 0; i < 2; i++) {
if (v[i].relflg[0] != 2) {
p = i;
break;
}
}
if (p == -1) {
relvelo = setVelo(trkdata,Trk,trkinf,cominf,step_,&velo); /* velocity set */
} else {
/* setVelo0(trkdata,Trk,v[p],&relvelo,trkinf,cominf,step_); */
setVelo0(trkdata,Trk,v[p],&relvelo,trkinf,cominf,step_);
}
}
/*velo = setVelo0(trkdata,Trk,v[notes - 1],&relvelo,trkinf,cominf,step_);*/
relvelo = setVelo(trkdata,Trk,trkinf,cominf,step_,&velo); /* velocity set */
if (velo < 0) { /* no velocity == use default */
velo = 0x80;
}
if (trkinf[Trk].veloseqsw) {
vSeqLoopChk(Trk,trkinf);
}
*trkdata[Trk].zmd++ = endchar == ')'? 0x84 : 0x85;
/*
if (delay != trkinf[Trk].pdelay) {
note[0] += 0x80;
trkinf[Trk].pdelay = delay;
}
*/
if ((trkinf[Trk].pdelay = delay) != 0) {
note[0] += 0x80;
}
*trkdata[Trk].zmd++ = note[0];
/*
if (ptime != trkinf[Trk].ptime) {
note[1] += 0x80;
trkinf[Trk].ptime = ptime;
}
*/
if ((trkinf[Trk].ptime = ptime) != 0) {
note[1] += 0x80;
trkinf[Trk].ptime = ptime;
}
*trkdata[Trk].zmd++ = note[1];
if (note[0] >= 0x80) {
trkdata[Trk].zmd += putZvar(trkdata[Trk].zmd, delay);
}
if (note[1] >= 0x80) {
trkdata[Trk].zmd += putZvar(trkdata[Trk].zmd, ptime);
}
if (step_) {
checkRenpu(trkdata,Trk,trkinf,1);
}
incrementStepCounters(&trkinf[Trk], step_);
trkdata[Trk].zmd += putStepGate(trkdata[Trk].zmd, trkinf[Trk].r->prev,
step_,gate_);
if (relvelo < 0) {
*trkdata[Trk].zmd++ = velo;
} else if (relvelo > 0) {
*trkdata[Trk].zmd++ = velo + 192;
} else {
*trkdata[Trk].zmd++ = 0x80;
}
if (++*qpos >= trkinf[Trk].quantizenum) {
*qpos = 0;
}
}
return zms;
}
UBYTE *makeZmdAutoPortament(UBYTE *zms, TRKCHINF *trkdata,
TRKINF *trkinf, const BYTE target[])
{
int trk;
LINEDATA *ld_ = ld;
UBYTE *linebuf_ = linebuf;
UBYTE *zms_ = zms;
for (trk = 0; target[trk] >= 0; trk++) {
const int Trk = target[trk];
const char *p[] = {"off","on",NULL};
DWORD para[2] = {0, 0};
int err, i;
UBYTE sw = 0, swmask = 0x80;
ld = ld_;
zms = zms_;
linebuf = linebuf_;
zms = getnum4(zms,¶[0],&err, p, 0);
zms = skipSpc(zms);
if (err) {
para[0] = -1;
}
*trkdata[Trk].zmd++ = 0xF6;
*trkdata[Trk].zmd++ = para[0];
for (i = 0; i < 2; i++) {
if (*zms == ',') {
zms++;
}
zms = getnum2(zms,¶[i],&err);
zms = skipSpc(zms);
if (!err) {
sw |= swmask;
}
swmask >>= 1;
}
*trkdata[Trk].zmd++ = sw;
swmask = 0x80;
for (i = 0; i < 2; i++) {
if (sw & swmask) {
putWord(trkdata[Trk].zmd, para[i]);
trkdata[Trk].zmd += 2;
}
swmask >>= 1;
}
}
return zms;
}
UBYTE *makeZmdAutoPortamentSwitch(UBYTE *zms, TRKCHINF *trkdata, const BYTE target[])
/* [auto_portament.switch] */
{
int trk, err;
DWORD para;
const char *p[] = {"off","on",NULL};
zms = getnum4(zms,¶,&err, p, 0);
if (!err) {
for (trk = 0; target[trk] >= 0; trk++) {
const int Trk = target[trk];
*trkdata[Trk].zmd++ = 0xf6;
*trkdata[Trk].zmd++ = para;
*trkdata[Trk].zmd++ = 0;
}
} else {
zmserror("[AUTO_PORTAMENT.SWITCH] require its parameter.",line,linebuf,zms,4,1);
}
return zms;
}